package org.come.control;

import org.come.Frame.GoodDetailedJframe;
import org.come.Frame.TaobaoCourtMainJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.action.FromServerAction;
import org.come.bean.ApplyPayBean;
import org.come.bean.LoginResult;
import org.come.bean.UseCardBean;
import org.come.until.GsonUtil;

import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.time.TimeLimit;

/**
 * 充值仙玉,元宝
 * 
 * @author 黄建彬
 * 
 */
public class ApplyPayControl implements FromServerAction {

	@Override
	public void controlMessFromServer(String mes, String type) {
		// String mesProcess[] = mes.split("//");
		if ("applypay".equals(type)) {
			ApplyPayBean applyPayBean = GsonUtil.getGsonUtil().getgson().fromJson(mes, ApplyPayBean.class);
			LoginResult loginResult=RoleData.getRoleData().getLoginResult();
			if (applyPayBean.getAddX()!=null) {
				loginResult.setCodecard(loginResult.getCodecard().add(applyPayBean.getAddX()));
				GoodDetailedJframe.getGoodDetailedJframe().getGoodDetailedJpanel().getYonghuXianyu().setText(loginResult.getCodecard() + "");
				TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getJadeNum().setText(loginResult.getCodecard() + "");
			}
			if (applyPayBean.getAddC()!=null) {
				loginResult.setMoney(loginResult.getMoney()+applyPayBean.getAddC().intValue());
			}
			if (applyPayBean.getAddM()!=null) {
				loginResult.setPaysum(loginResult.getPaysum().add(applyPayBean.getAddM()));//累计充值
				loginResult.setDaypaysum(loginResult.getDaypaysum().add(applyPayBean.getAddM()));//每日累计充值
				TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getMoney().setText(loginResult.getMoney() + "");//增加系统发放积分实时更新 即时显示----小情调加
				//刷新VIP界面
				if(TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getTaobaoCourtCardJpanel().getVipShopJpanel().isVisible()){
					TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getTaobaoCourtCardJpanel().getVipShopJpanel().getShop();
				}
			}
			if (applyPayBean.getLowOrHihtpack()!=null) {
				loginResult.setLowOrHihtpack(applyPayBean.getLowOrHihtpack().intValue());
				//刷新冲级界面
				
				
			}
			if (applyPayBean.getDayandpayorno()!=null) {
				loginResult.setDayandpayorno(loginResult.getDayandpayorno());
				loginResult.setDayfirstinorno(1);
				//刷新连充奖励界面
				
			}
            if (applyPayBean.getUseCardBean()!=null) {
            	UseCardBean cardBean = applyPayBean.getUseCardBean();
    			TimeLimit.getLimits().addLimit(cardBean.getName(), cardBean.getType(), cardBean.getSkin(), cardBean.getValue(), cardBean.getTime());
			}
            if (applyPayBean.getVIPBean()!=null) {
            	UseCardBean cardBean = applyPayBean.getVIPBean();
    			TimeLimit.getLimits().addLimit(cardBean.getName(), cardBean.getType(), cardBean.getSkin(), cardBean.getValue(), cardBean.getTime());
			}
            if (applyPayBean.getMsg()!=null) {
            	ZhuFrame.getZhuJpanel().addPrompt2(applyPayBean.getMsg());
			}
//			// 切分元宝和累计金额
//			String[] mesage = mes.split("\\-");
//			LoginResult loginResult=RoleData.getRoleData().getLoginResult();
//			// 设置获取的仙玉
//			loginResult.setCodecard(loginResult.getCodecard().add(new BigDecimal(mesage[0])));
//			// 设置累计金额
//			loginResult.setMoney(Integer.valueOf(mesage[1].trim()));
//			// 设置进面板
//			GoodDetailedJframe.getGoodDetailedJframe().getGoodDetailedJpanel().getYonghuXianyu().setText(loginResult.getCodecard() + "");
//			TaobaoCourtMainJframe.getTaobaoCourtJframe().getTaobaoCourtMainJpanel().getJadeNum().setText(loginResult.getCodecard() + "");
//			// 提示充值成功
//			FrameMessageChangeJpanel.addtext(5, "充值" + mesage[0] + "元宝!!", null, null);
//			FrameMessageChangeJpanel.addtext(5, "当前" + mesage[1].trim() + "积分！！", null, null);
//			// 头像提示框
//			ImageMixDeal.userimg.Dialogue("充值" + mesage[0] + "元宝!!");
		} else {
			// 提示充值成功
			FrameMessageChangeJpanel.addtext(6, "充值失败!!", null, null);
			// 头像提示框
			ImageMixDeal.userimg.Dialogue("充值失败!!");
		}
	}
}
